﻿@model QuanLyGiaoVuUI.Models.GiangVienClient.DangKyLichThiViewModel
@{
    Layout = null;
}


<div id="page-heading">
    <div class="block">
        <input type="hidden" value="" id="thutugiangvien" />
        @{Html.EnableClientValidation();}
        @using (Ajax.BeginForm("DangKyLichThi", "GiangVienClient", new AjaxOptions
        {
            HttpMethod = "POST",
            OnSuccess = "DangKyLichThiSuccess"
        }))
        {
            <table class="form" style="width: 100%">
                <tr>
                    <td>
                        @if (Model.MaLichThi != null && Model.MaLichThi != Guid.Empty)
                        {
                            <input type="hidden" value="@Model.MaLichThi" name="MaLichThi" />
                        }
                        <div class="editor-label">
                            Mã lớp - Tên môn học
                        </div>
                    </td>
                    <td>
                        <input type="hidden" name="MaLopMonHoc" value="@Model.MaLopMonHoc" />
                        <a style="text-decoration: none; cursor: pointer;">@Model.LopMonHoc.MaLopVaTenMonHoc</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            Ngày thi
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <input type="text" value="@Model.NgayGio.ToShortDateString()" name="NgayThi" id="NgayThi" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            Giờ thi:
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <input type="text" name="GioThi" value="@(Model.NgayGio.Hour >= 10 ? Model.NgayGio.Hour.ToString() : "0" + Model.NgayGio.Hour.ToString()):@(Model.NgayGio.Minute >= 10 ? Model.NgayGio.Minute.ToString() : "0" + Model.NgayGio.Minute.ToString())" id="GioThi" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            Thời gian làm bài:
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <input type="text" id="ThoiGianLamBai" value="@Model.ThoiGianLamBai" name="ThoiGianLamBai" />
                        </div>
                    </td>
                </tr>
                       <tr>
                    <td>
                        <div class="editor-label">
                            Giờ kết thúc:
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            @{var toHour = Model.NgayGio.AddMinutes(Model.ThoiGianLamBai).Hour < 10 ? "0" + Model.NgayGio.AddMinutes(Model.ThoiGianLamBai).Hour.ToString() : Model.NgayGio.AddMinutes(Model.ThoiGianLamBai).Hour.ToString();
                              var toMinute = Model.NgayGio.AddMinutes(Model.ThoiGianLamBai).Minute < 10 ? "0" + Model.NgayGio.AddMinutes(Model.ThoiGianLamBai).Minute.ToString() : Model.NgayGio.AddMinutes(Model.ThoiGianLamBai).Minute.ToString();
        }
                            <input type="text" id="GioKetThuc" value="@toHour : @toMinute" name="ThoiGianLamBai" />
                        </div>
                    </td>
                </tr>
         
                <tr>
                    <td>
                        <div class="editor-label">
                            Hình thức thi:
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <select name="HinhThucThi">
                                <option value="0">Lý thuyết</option>
                                <option value="1">Báo cáo</option>
                            </select>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="editor-label">
                            @Html.LabelFor(model => model.GhiChu)
                        </div>
                    </td>
                    <td>
                        <div class="editor-field">
                            <textarea name="GhiChu">@Model.GhiChu</textarea>
                        </div>
                    </td>
                </tr>
            </table>
            <p>
                <input id="dangKyLichThi-submit" style="display: none" type="submit" value="Lưu" />
            </p>
        }
    </div>
</div>

<script>
    function DangKyLichThiSuccess(data) {
        if (data.success == true) {
            window.location.reload(true);
        }
        else {
            ToastManager.showStickyWarningToast(data.message);
        }
    }
</script>
